package willispace;

import entities.Builder;
import entities.Diamond;
import entities.Factory;
import entities.Gas;
import entities.Transporter;
import entities.Worker;
import graphics.PropertiesPanel;
import java.util.LinkedList;
import java.util.HashMap;

/**
 * Database of all entities, maps, global supplies
 * Cont
 * @author mateusz
 */
public class Database {

    // ===================
    // MAP
    // ===================
    /**
     * Current map
     * @see Map
     */
    public static Map map = null;
    
    // ===================
    // ROBOTS
    // ===================
    
    public static int workersCounter = 0;
    public static int transportersCounter;
    
    /**
     * Builder
     * @see Builder
     */
    public static Builder builder = null;
    /**
     * List of Workers
     * @see Worker
     */
    public static final LinkedList<Worker> workers = new LinkedList<Worker>();
    /**
     * List of Transporters
     * @see Transporter
     */
    public static final LinkedList<Transporter> transporters = new LinkedList<Transporter>();
    
    // ===================
    // SUPPLIES
    // ===================
    /**
     * Global gas supply
     */
    public static int globalGasSupply = 0;
    /**
     * global diamond supply
     */
    public static int globalDiamondSupply = 0;
    /**
     * List of gas supplies
     * @see Gas
     */
    public static final LinkedList<Gas> gases = new LinkedList<Gas>();
    /**
     * List of diamond supplies
     * @see Diamond
     */
    public static LinkedList<Diamond> diamonds = new LinkedList<Diamond>();
    
    // ===================
    // BUILDINGS
    // ===================
    public static int factoriesCounter = 0;
    /**
     * List of all factories
     * @see Factory
     */
    public static final LinkedList<Factory> factories = new LinkedList<Factory>();
    /**
     * Set of global key-value properties
     */
    public static final HashMap<String, String> globalProperties = new HashMap<String, String>();

    /**
     * Updates global properties to current values
     * @see PropertiesPanel
     */
    public static void updateGlobalProperties() {
        globalProperties.put("totalWorkers", Integer.toString(workers.size()));
        globalProperties.put("totalTransporters", Integer.toString(transporters.size()));
        globalProperties.put("totalFactories", Integer.toString(factories.size()));
        globalProperties.put("globalGasSupply", Integer.toString(globalGasSupply));
        globalProperties.put("globalDiamondSupply", Integer.toString(globalDiamondSupply));
    }
}
